This sample code demonstrates how to use the AppleTalk Data Stream Protocol (ADSP) to exchange data between two network processes. The code makes use of the ADSP Attention channel mechanism to send the clock time of the source machine to the target machine. Similarly, the ADSP dspRead and dspWrite calls are used to send messages back and forth from the source to the target. Most calls are made asynchronously using completion routines. The parameter block for a given call is taken from an OS Queue of parameter blocks that the application builds. This technique is described in more detail in Develop magazine Issue #13 "Asynchronous Routines on the Macintosh" by Jim Luther.
INSTRUCTIONS
Launch the application on two different machines on the network. The application registers itself with the Name Binding Protocol (nbp) once it is launched. It uses the Network Identity (found in the Sharing Setup Control Panel) for the nbp entity name object field and “moof” as the type field.
Use the “Zone”, “Type” and “Object” popup menus to identify and select other machines that are running the application. Once a target machine has been selected, press the “Connect” button and an ADSP connection will be established between the two machines. You can send text to the target machine by typing a message and then pressing the <enter> key. The target machine can also send text to the originating machine in the same manner. If this happens the text will show up in the “Incoming message” box. Additionally, the clock time of the target machine is displayed in the “Time from remote Mac” box. The clock time is sent across the connection using the attention mechanism. To close the connection, simply press the <disconnect> button on either machine.